﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web;

namespace zielonka.co.uk.extensions.system.web
{
	//Description:	Make easily accessible some functions available in HttpUtility into an Extension.
	/*
		string html = "<title>this is the Test Title</title>";
		string url = "http://www.domain.com?q=test&a=123&g=test";

		Console.WriteLine("UrlEncode: {0}", url.UrlEncode());
		Console.WriteLine("UrlDecode: {0}", url.UrlDecode());
		Console.WriteLine("UrlPathEncode: {0}", url.UrlPathEncode());
		Console.WriteLine("HtmlEncode: {0}", html.HtmlEncode());
		Console.WriteLine("HtmlDecode: {0}", html.HtmlDecode());

		int idx = url.IndexOf('?');
		String querystring = null;
		if (idx >= 0)
		{
			querystring = (idx < url.Length - 1) ? url.Substring(idx + 1) : String.Empty;
		}

		System.Collections.Specialized.NameValueCollection coll = querystring.ParseQueryString();
		Console.WriteLine("   [INDEX] KEY        VALUE");
		for (int i = 0; i < coll.Count; i++)
			Console.WriteLine("   [{0}]     {1,-10} {2}", i, coll.GetKey(i), coll.Get(i));

	 */
	public static partial class WebExtensions
	{


		public static string HtmlDecode(this string data)
		{
			return HttpUtility.HtmlDecode(data);
		}

	}
}
